<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录成功</title>
    <style type="text/css" media="screen">
         *{margin:0; padding: 0;}
        body{background:url(img/5.jpg) no-repeat center center fixed; background-size: cover; font-family: 微软雅黑;}
        div{width: 500px;height: 200px;margin:80px auto; text-align: center;background-color: rgba(250,250,250,.4); border-radius: 50px; line-height: 200px;font-size: 20px;}
    </style>
</head>
<body>
   <?php

      error_reporting(0); 
      session_start(); 
      $conn=mysql_connect("localhost","root","") or die("连接服务器失败".mysql_error());
      $db_name="login" or die("连接数据库失败".mysql_error());
      mysql_select_db($db_name,$conn);
      mysql_query("set names'utf8'");

      $username=$_POST["user"];
      $userpwd=$_POST["pwd"];
  
 

    if ($username && $userpwd) {//如果用户名和密码都不为空
  $sql = "select * from user where Uname='$username' and Upwd='$userpwd'";
  $result = mysql_query($sql, $conn);
  $row = mysql_num_rows($result);//返回一个数值
      if ($row) {
        echo "<div>
          登录成功，欢迎回来！5S后跳转到首页！
        </div>";
        print'<meta http-equiv="refresh" content="5;url=首页.html">';
      } else {
        echo "
          <script type='text/javascript'> alert('用户名或密码不正确');
          location='login.html';</script>";}
    } else {//如果用户名或密码为空
      echo "
        <script type='text/javascript'> alert('用户名或密码未填写，请输入！');
          location='login.html';</script>";
    }
     mysql_close($conn);
        ?>

</body>
</html>